﻿Imports System.Web.UI.WebControls

Namespace DotNetNuke.Modules.ActiveForums
    Partial Public Class af_topicstatus
        Inherits ForumBase
        Private _status As Integer = -1
        Private _autoPostBack As Boolean = True
        Public Property Status() As Integer
            Get
                Return _status
            End Get
            Set(ByVal value As Integer)
                _status = value
            End Set
        End Property
        Public Property AutoPostBack() As Boolean
            Get
                Return _autoPostBack
            End Get
            Set(ByVal value As Boolean)
                _autoPostBack = value
            End Set
        End Property
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            drpStatus.AutoPostBack = AutoPostBack
            For Each li As ListItem In drpStatus.Items
                li.Text = Utilities.GetSharedResource(li.Text)
            Next
            If Not Page.IsPostBack Then
                drpStatus.SelectedIndex = drpStatus.Items.IndexOf(drpStatus.Items.FindByValue(Status.ToString))
            End If
        End Sub

        Private Sub drpStatus_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles drpStatus.SelectedIndexChanged
            If AutoPostBack = True Then
                Dim intStatus As Integer
                intStatus = CType(drpStatus.SelectedItem.Value, Integer)
                If intStatus >= -1 And intStatus <= 3 Then
                    DataProvider.Instance.Topics_UpdateStatus(PortalId, ModuleId, TopicId, -1, intStatus, -1, Me.UserId)
                End If
                Response.Redirect(Request.RawUrl())
            End If

        End Sub
    End Class
End Namespace
